package exercises;

import java.util.ArrayList;
import java.util.Collections;

/**
 * Created with IntelliJ IDEA
 * Description:
 * User:22954
 * Date:2024-02-22
 * Time:17:06
 */
@SuppressWarnings("all")
public class Exercise1 {
    public static void main(String[] args) {
        News new1 = new News("新冠确诊病例超十万,百万印度教信徒赴恒河\"圣浴\"引民众担忧");
        News new2 = new News("男子突然想起两个月前钓的鱼还在网兜里,捞起一看赶紧放生");
        ArrayList<News> news = new ArrayList<>();
        news.add(new1);
        news.add(new2);
        Collections.reverse(news);
        for (News news1 : news) {
            String title = news1.getTitle();
            if (title.length() > 15) {
                String strings = title.substring(0, 15);
                System.out.println(strings + "...");
            } else {
                System.out.println();
            }
        }
    }
}
@SuppressWarnings("all")
class News {
    private String title;
    private String content;

    public News(String title) {
        this.title = title;
    }

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getContent() {
        return content;
    }

    public void setContent(String content) {
        this.content = content;
    }

    @Override
    public String toString() {
        return "News{" +
                "title='" + title + '\'' +
                '}';
    }
}